<?php
/**
 * Author Lion
 * Date   2018-02-24
 * Func   快3
 */
defined('IN_YuLin') || exit('NO PERMIT!');

//	返回中奖金额	data为订单信息

function PrizeCount_k3($data,$result)
{
	if(!$data)
	{
		return 0;
	}
	$result = explode(',',$result);
	print_r($data['cn_play']);

	//默认值
	$up['winner'] = '1';
	$up['preize'] = '0.00';
	//	和值
	if($data['cn_play'] == '和值')
	{
		$hezhi = array_sum($result);
		if($hezhi > 10){$type='大';}else{$type='小';}
		if($hezhi%2==0){$types='双';}else{$types='单';}
		
		if($data['betting_no'] == $type || $data['betting_no'] == $types || intval($data['betting_no']) == $hezhi){
			$up['winner'] = '2';
			$up['prize'] = $data['money'] * $data['	'];
		}
	}
	
	//	三连号通选
	if($data['cn_play'] == '三连号通选')
	{
		$a = implode('',$result);
		if(in_array(implode('',$result),[111,222,333,444,555,666]))
		{
			$up['winner'] = '2';
			$up['prize'] = $data['money'] * $data['odds'];
		}
	}

	//	三同号单选
	if($data['cn_play'] == '三同号单选')
	{
		//	必须是三个相同的值
		$tmp2 = array_count_values($result);
		if(count($tmp2) == 3)
		{
			$up['winner'] = '2';
			$up['prize'] = $data['money'] * $data['odds'];
		}
	}	

	//	三不同号
	if($data['cn_play'] == '三不同号')
	{
		//	必须三个数不一样
		$tmp2 = array_count_values($result);
		
		if(count($tmp2) < 3)
		{
			$up['winner'] = '2';
			$up['prize'] = '0.00';
		}
		
		$tmp3 = 0;
		$tmp = explode(',',$data['betting_no']);
		
		foreach($result as $t)
		{
			in_array($t,$tmp) && $tmp3++;
		}
		
		if($tmp3 > 2)
		{
			$up['winner'] = '2';
			$up['prize'] = $data['money'] * $data['odds'];
		}
	}

	//	三连号通选
	if($data['cn_play'] == '三连号通选')
	{
		
		if(in_array(implode('',$result),[123,234,345,456])){
			$up['winner'] = '2';
			$up['prize'] = $data['money'] * $data['odds'];
		}
	}

	//	二同号复选
	if($data['cn_play'] == '二同号复选')
	{
		//	二同号最多2个数
		$tmp2 = array_count_values($result);
		if(count($tmp2) > 2)
		{
			$up['winner'] = '1';
			$up['prize'] = '0.00';
		}
		
		$tmp = explode(' ',$data['betting_no']);
	
		$tmp0 = 0;
		foreach($tmp as $t)
		{
			$t = substr($t,1);	//	同号，取一个数字即可
			$tmp2[$t] > 1 && $tmp0++;
		}
		
		if($tmp0)
		{
			$up['winner'] = '2';
			$up['prize'] = $data['money'] * $data['odds'];
		}
	}

	//	二同号单选
	if($data['cn_play'] == '二同号单选')
	{
		//	二同号最多2个数
		$tmp2 = array_count_values($result);
		if(count($tmp2) > 2)
		{
			return 0;
		}
		
		$tmp = explode('|',$data['rednum']);
		$tmp[0] = explode(',',$tmp[0]);
		$tmp[1] = explode(',',$tmp[1]);
		
		$tmp0 = $tmp1 = 0;
		foreach($tmp[0] as $t)
		{
			$t = substr($t,1);	//	同号，取一个数字即可
			$tmp2[$t] > 1 && $tmp0++;	//	3个即豹子
		}
		foreach($tmp[1] as $t)
		{
			$tmp2[$t] == 1 && $tmp1++;
		}
		
		return $tmp0 && $tmp1 ? $data['maxprize'] * $data['times'] : 0;
	}
	
	//	二不同号
	if($data['cn_play'] == '二不同号')
	{
		$tmp3 = 0;
		$tmp = explode(',',$data['betting_no']);
		foreach($result as $t)
		{
			in_array($t,$tmp) && $tmp3++;
		}
		if($tmp3 >= 2)
		{
			$up['winner'] = '2';
			$up['prize'] = $data['money'] * $data['odds'];
		}
	}
	
	
	
	//print_r($up);
}